package com.xcjh.module_push

import android.os.Bundle
import android.widget.Button
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.messaging.FirebaseMessaging
import com.xcjh.base_lib.Constants
import com.xcjh.base_lib.base.activity.BaseActivity
import com.xcjh.base_lib.utils.loge

@Route(path = Constants.Router.Push.A_Push_MAIN)
class PushMainActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.push_activity_main)
        findViewById<Button>(R.id.push).setOnClickListener {
           // startMyActivity<ContentActivity> {  }
            FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener{task ->
                if (!task.isSuccessful) {
                    "Fetching FCM registration token failed===${task.exception}".loge("push====token===")
                    return@OnCompleteListener
                }

                // Get new FCM registration token
                val token = task.result

                // Log and toast
                val msg = token
                msg.loge("push====token===")
            })

        }

    }
}